package com.cd.javacxy.module.web.controller;

import com.cd.javacxy.common.model.enums.ResponseCode;
import com.cd.javacxy.common.model.vo.AjaxResponse;
import com.cd.javacxy.module.web.service.CxyUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotBlank;

/**
 * @author yanghy
 * @date 2019/11/17
 */
@Validated
@RestController
@RequestMapping("/common/")
public class CommonController {

    @Autowired
    private CxyUserService userService;

    /**
     * blur事件得到用户头像
     *
     * @param account 账户名
     * @return AjaxResponse
     */
    @RequestMapping("findHeadImage")
    public AjaxResponse<Object> findHeadImage(@NotBlank(message = "账号不能为空") String account) {
        //AjaxResponse<Object> ajaxResponse = new AjaxResponse<Object>();
        String headIcon = userService.findHeadIcon(account);
        return AjaxResponse.builder()
                .code(ResponseCode.SUCCESS.getCode())
                .errorMsg("success")
                .data(headIcon).build();

    }
}
